<?php
/**
 * Created by PhpStorm.
 * User: zhangxilu
 * Date: 2017/12/19
 * Time: 下午11:35
 */

namespace backend\server;



use common\logic\RoleLogic;
use common\server\Server;
use yii\helpers\ArrayHelper;

class RoleServer extends Server
{
    /**
     * @var integer 超级管理员id
     */
    const ROLE_SUPER = 1;

    public function getRoleName($role_id)
    {
        $role = RoleLogic::instance()->getById($role_id);
        return empty($role) ? '' : $role->name;
    }

    public function getRole()
    {
        $all = RoleLogic::instance()->getAllRule();
        $all = ArrayHelper::map($all, 'id', 'name');
        unset($all[self::ROLE_SUPER]);
        return $all;
    }
}